import 'dart:io';
import 'dart:typed_data';

import 'package:flutter/services.dart';

class AppChannel {
  AppChannel._();

  static const MethodChannel _channel = const MethodChannel('plugins.io/app');

  /// 获取某一个图片数据
  static Future<Uint8List?> getImageResource(String imageName, {String defType = "drawable"}) async {
    return await _channel.invokeMethod("getImageResource", {"imageName": imageName, "defType": defType});
  }

  /// ios的获取启动页api,android使用上面的接口，这个接口在ios上实现
  static Future<Uint8List?> get getSplashImageResource async {
    if (Platform.isAndroid) return null;
    return await _channel.invokeMethod("getSplashImageResource");
  }
}
